/*
 * @Author: szx
 * @Date: 2022-03-05 14:47:12
 * @LastEditTime: 2022-03-05 14:49:27
 * @Description:
 * @FilePath: \leetcode\700-799\700\700_2.js
 */
/**
 * @param {TreeNode} root
 * @param {number} val
 * @return {TreeNode}
 */
var searchBST = function (root, val) {
    if(!root) return null;
    if (root.val == val) return root;
    else if (val < root.val) return searchBST(root.left, val);
    else return searchBST(root.right, val);
};
